<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" 
	template="/template/template.xhtml">
	
  <ui:define name="center">
  
  <h1 class="title ui-widget-header ui-corner-all">${msg['admin.list.title']}</h1>

  <p:panel header="${msg['admin.list.addBook']}" id="addBook">
  <p:messages for="newbookform" showSummary="false" showDetail="true"/>
  <h:form id="newbookform" enctype="multipart/form-data">
	 	<h:panelGrid columns="2">  
  			<h:outputText value="${msg['admin.form.name']}*"/>
  			<p:inputText id="title" value="#{bookBean.book.title}" required="true" requiredMessage="${msg['admin.error.title']}"/>
  			
  			<h:outputText value="Image*"/>
			<p:fileUpload id="image" value="#{bookBean.file}" mode="simple" required="true" requiredMessage="${msg['admin.error.file']}"/>
			
  			<h:outputText value="${msg['admin.form.date']}*"/>
            <p:calendar value="#{bookBean.book.date}" id="cal" showButtonPanel="true" required="true" requiredMessage="${msg['admin.error.date']}"/>
             
           	<h:outputLabel for="spinnerStep" value="${msg['admin.table.price']}*" />  
           	<p:spinner value="#{bookBean.book.price}" id="spinnerStep" stepFactor="0.5" required="true" validator="#{bookBean.validatePrice}"/>
            
           	<h:outputLabel value="${msg['admin.form.category']}*" />
           	<p:selectOneMenu value="#{bookBean.categoryId}" required="true" requiredMessage="${msg['admin.error.category']}" > 
           		<f:selectItems value="#{categoryListBean.categories}" var="category" itemLabel="#{category.title}" itemValue="#{category.id}"/> 
       	   	</p:selectOneMenu>
       	  
       	   	<h:outputText value="${msg['admin.form.authors']}* : " />
	       	<p:selectManyMenu value="#{bookBean.authorsId}" required="true" requiredMessage="${msg['admin.error.author']}">  
	        	<f:selectItems value="#{authorBean.authors}" var="author" itemLabel="#{author.firstName} #{author.lastName}" itemValue="#{author.id}" /> 
	      	</p:selectManyMenu>  
       
  			<p:commandButton action="#{bookBean.save}" value="${msg['admin.form.add']}" ajax="false"/>
  		</h:panelGrid>
  		<h:outputText styleClass="comment" value="${msg['admin.form.required']}" />
  	</h:form>
  </p:panel>
  </ui:define>

</ui:composition>